<template>
    <div>

    </div>
</template>
<script>
import cookie from '@/util/cookie'
import refreshToken from '@/util/refreshToken'
import {login, sendMessage, getUserInfo} from '@/api/accountApi'
import {wwwUrl} from '@/config/config'
export default {
    async mounted () {
        var authToken = cookie.get('authToken')
        if (authToken) {
            try {
                await refreshToken.refreshToken()
                let userInfo = JSON.parse(localStorage.userInfo)
                let result = await getUserInfo({userName: userInfo.userName})
                this.$store.commit('user/setUserInfo', result.userInfo)

                if (location.origin == result.redirectUrl) {
                    this.$router.replace('county') 
                    return
                }

                if (result.redirectUrl) {
                    location.href = result.redirectUrl
                } else {
                    this.$router.replace('county') 
                }
               
            } catch (error) {
                this.$router.replace('login')
            }
            
        } else {
            this.$router.replace('login')
        }
    }
}
</script>
<style scoped>

</style>
